package com.aipolice.service;


import com.aipolice.dao.AdminDAO;
import com.aipolice.pojo.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminService {
    @Autowired
    AdminDAO adminDAO;

    public List<Admin> list() {
        return adminDAO.findAll();
    }

    public boolean isExist(String name) {
        Admin admin = adminDAO.findAdminByUsername(name);
        return null != admin;
    }

    public Admin get(String name, String password) {
        return adminDAO.getAdminByUsernameAndPassword(name, password);
    }


    public void add(Admin admin) {
        adminDAO.save(admin);
    }
}
